home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / tool / vdgear / src / window.c < prev   
Text File  |  1994-11-16  |  19KB  |  867 lines

  1. /*
  2.  *    VIDEO・GEAR
  3.  *    "window.c"
  4.  *    by Good-Chy
  5.  */
  6.  
  7. #include    "video.h"
  8.  
  9. FILE    *pf_t;
  10. char    *tiff;
  11. char    *picture_name;
  12. EFFECT    effect_buf;
  13. PICTURE    picture_buf1, picture_buf2;
  14. MIXING    mixing_buf;
  15. SOUND        sound_buf;
  16. CD        cd_buf;
  17.  
  18. /******************************************************************************
  19.  *    エラ-ウィンドウ
  20.  */
  21.  
  22. void    err_window(int err, int x, int y)
  23.     {
  24.     BUTTON    *p;
  25.  
  26.     p = window_open(x,y,200,45,324,0);
  27.     p = create(p, 84,24,32,17, 0, close);
  28.     sprint(err_msg[err],x+6,y+17,15,8,12,12,4);
  29.     }
  30.  
  31. /******************************************************************************
  32.  *    確認ウィンドウ
  33.  */
  34.  
  35. void    con_win(int con)
  36.     {
  37.     BUTTON    *p;
  38.  
  39.     p = window_open(230,217,177,45,324,50);
  40.     switch(con)
  41.         {
  42.         case    0:p = create(p, 41,22,32,17,0,pro_exit);         break;
  43.         case    1:p = create(p, 41,22,32,17,0,all_clear_sub);     break;
  44.         case    2:p = create(p, 41,22,32,17,0,data_load);         break;
  45.         case    3:p = create(p, 41,22,32,17,0,data_save);         break;
  46.         case    4:p = create(p, 41,22,32,17,0,data_save);         break;
  47.         }
  48.  
  49.     p = create(p,111,22,31,17,0,close);
  50.     sprint(con_msg[con],238,233,15,8,12,12,4);
  51.     }
  52.  
  53. /******************************************************************************
  54.  *    エフェクトリストのウィンドウ
  55.  */
  56.  
  57. void    set_effect()            /* エフェクト一覧で設定された */
  58.     {
  59.     char    sel;
  60.     int    x, y;
  61.  
  62.     sel = win[active].last->number;
  63.     effect_buf.effect  = sel+1;
  64.     picture_buf1.effect = sel+1;
  65.  
  66.     close();
  67.     x = win[active].last->bx;
  68.     y = win[active].last->by;
  69.     EGB_paintMode(egb_work,0x22);
  70.     box_full(x+1,y+1,x+119,y+12,4,4,0);
  71.     sprint(eff_str[sel],x,y+12,15,8,12,12,4);
  72.     }
  73.  
  74. void    effect()                /* エフェクト一覧表を開く */
  75.     {
  76.     BUTTON    *p;
  77.     int    wy,i,j;
  78.  
  79.     wy = win[active].last->by+17;
  80.     p = window_open(126,wy,388,119,0,97);
  81.  
  82.     for (i=0 ; i<5 ; i++)
  83.         {
  84.         for (j=0 ; j<3 ; j++)
  85.             {
  86.             p = create(p, j*127+7, i*17+33, 120, 13, 0, set_effect);
  87.             }
  88.         }
  89.     p = create(p, 350, 8, 31, 17, 0, close);
  90.     }
  91.  
  92. /******************************************************************************
  93.  *    パソコン画像ウィンドウ
  94.  */
  95.  
  96. char    *pic_name(char *name)        /* フルパスからファイル名を取り出す */
  97.     {
  98.     int    len;
  99.  
  100.     len = strlen(name);
  101.     while((*(name+len) != '\\') && (len>0))    { len--; }
  102.  
  103.     return (name+len+1);
  104.     }
  105.  
  106. void    picture_print(int stp, int x, int y)    /* 絵を表示する */
  107.     {
  108.     int    dx,dy;
  109.     char    *p;
  110.  
  111.     dx = stp % 8 * 40;
  112.     dy = stp / 8 * 30+60;
  113.     EGB_writePage(egb_work,0x81);
  114.     p = get_vram(32,dx,dy,dx+39,dy+29);
  115.     EGB_writePage(egb_work,1);
  116.     put_vram(p,x,y,x+39,y+29);
  117.     EGB_writePage(egb_work,0);
  118.     free(p);
  119.     }
  120.  
  121. void    pic_close()                    /* 縮小表示ウィンドウを閉める */
  122.     {
  123.     int    x1,x2,y1,y2;
  124.  
  125.     x1 = win[active].wx/2;
  126.     y1 = win[active].wy/2;
  127.     x2 = win[active].dx/2;
  128.     y2 = win[active].dy/2;
  129.  
  130.     EGB_paintMode(egb_work,0x22);
  131.     EGB_writePage(egb_work,1);
  132.     box_full(x1,y1,x1+x2,y1+y2,0x8000,0x8000,0);
  133.     EGB_writePage(egb_work,0);
  134.  
  135.     free(tiff);
  136.     close();
  137.     }
  138.  
  139. void    pic_set_pos()                /* 絵の表示位置を決定する */
  140.     {
  141.     int    wx,wy;
  142.  
  143.     picture_buf1.x = picture_buf2.x;
  144.     picture_buf1.y = picture_buf2.y;
  145.     strcpy(picture_buf1.name, picture_buf2.name);
  146.     pic_close();
  147.  
  148.     wx = win[active].wx;
  149.     wy = win[active].wy;
  150.     EGB_paintMode(egb_work,0x22);
  151.     box_full(wx+87,wy+53,wx+205,wy+65,4,4,0);
  152.     box_full(wx+87,wy+70,wx+205,wy+82,4,4,0);
  153.     sprint(pic_name(picture_buf1.name),wx+87,313,15,8,12,12,4);
  154.     sprint("X:     Y:",wx+87,330,15,8,12,12,4);
  155.     sprintusing(picture_buf1.x*2,3,wx+111,330,15,8,12,12,4);
  156.     sprintusing(picture_buf1.y*2,3,wx+159,330,15,8,12,12,4);
  157.     }
  158.  
  159. void    set_pos()                    /* 絵の表示位置を変更する */
  160.     {
  161.     int    ch,x,y,tx,ty,wx,wy;
  162.  
  163.     MOS_rdpos(&ch,&x,&y);
  164.     tx = WORD(tiff+0)+1;
  165.     ty = WORD(tiff+2)+1;
  166.     wx = win[active].wx;
  167.     wy = win[active].wy;
  168.  
  169.     x = x-wx-2-tx/4;
  170.     y = y-wy-27-ty/4;
  171.     if (x<0)        { x = 0; }
  172.     if (y<0)        { y = 0; }
  173.     if ((x+tx/2)>159)    { x = 160-tx/2; }
  174.     if ((y+ty/2)>119)    { y = 120-ty/2; }
  175.  
  176.     EGB_writePage(egb_work,1);
  177.     EGB_paintMode(egb_work,0x22);
  178.     box_full((wx+2)/2,(wy+28)/2,(wx+2)/2+80,(wy+28)/2+60,0x8000,0x8000,0);    
  179.     put_vram_zoom((tiff+6),(wx+2+x)/2,(wy+28+y)/2,
  180.                     (wx+2+x)/2+tx/4-1,(wy+28+y)/2+ty/4-1,tx,ty);    
  181.     EGB_writePage(egb_work,0x81);
  182.     box_full(280,30,319,59,0x8000,0x8000,0);
  183.     put_vram_zoom((tiff+6),x/4+280,y/4+30,x/4+tx/8+279,y/4+ty/8+29,tx,ty);
  184.     EGB_writePage(egb_work,0);
  185.  
  186.     picture_buf2.x = x;
  187.     picture_buf2.y = y;
  188.     }
  189.  
  190. void    picture_pos(char *name)        /* 絵を縮小表示ウィンドウに読み込む */
  191.     {
  192.     BUTTON    *p;
  193.     int    x,y,tx,ty,wx,en;
  194.  
  195.     wx = win[1].wx;
  196.     p = window_open(wx+24,314,163,148,0,330);
  197.     p = create(p,2,27,159,119,0,set_pos);
  198.     p = create(p, 92,4,32,17,0,pic_set_pos);
  199.     p = create(p,128,4,31,17,0,pic_close);
  200.     p = create(p,128,4,31,17,0,close);
  201.     sprint(pic_name(name),wx+29,331,15,8,12,12,0);
  202.  
  203.     if (NULL == (tiff = tiff_load(name)))        /* 読み込みに失敗 */
  204.         {
  205.         close();
  206.         if (err == 1)    { en = 1; }
  207.         if (err == 2)    { en = 5; }
  208.         if (err == 3)    { en = 6; }
  209.         err_window(en,wx+5,303);
  210.         setmos(81);
  211.         return;
  212.         }
  213.     
  214.     x = WORD(tiff+0)+1;
  215.     y = WORD(tiff+2)+1;
  216.  
  217.     if (WORD(tiff+4) != 16)                    /* 32k色以外 */
  218.         {
  219.         close();
  220.         err_window(6,wx+5,303);
  221.         free(tiff);
  222.         setmos(81);
  223.         return;
  224.         }
  225.  
  226.     if ((x>320) || (y>240))                    /* サイズが大きい */
  227.         {
  228.         close();
  229.         err_window(7,wx+5,303);
  230.         free(tiff);
  231.         setmos(81);
  232.         return;
  233.         }
  234.  
  235.     tx = picture_buf1.x*2;
  236.     ty = picture_buf1.y*2;
  237.     if (x+tx>320)    { tx = 0; }
  238.     if (y+ty>240)    { ty = 0; }
  239.  
  240.     EGB_writePage(egb_work,1);
  241.     put_vram_zoom((tiff+6),(wx+26)/2+tx/4,171+ty/4,
  242.                         x/4+(wx+26)/2+tx/4-1,y/4+ty/4+170,x,y);    
  243.     EGB_writePage(egb_work,0x81);
  244.     EGB_paintMode(egb_work,0x22);
  245.     box_full(280,30,319,59,0x8000,0x8000,0);
  246.     put_vram_zoom((tiff+6),tx/8+280,ty/8+30,(tx+x)/8+279,(ty+y)/8+29,x,y);
  247.     EGB_writePage(egb_work,0);
  248.  
  249.     picture_buf2.x = tx/2;
  250.     picture_buf2.y = ty/2;
  251.     }
  252.  
  253. void    picture_load()                        /* 絵を読み込む */
  254.     {
  255.     char    *crrdir = NULL;
  256.  
  257.     close();
  258.     crrdir = _getcwd(crrdir,256);
  259.     if (strlen(crrdir) > 3)    { strcat(crrdir,"\\"); }
  260.     strcat(crrdir,key_buff);
  261.     strcpy(picture_buf2.name, crrdir);
  262.     picture_pos(crrdir);
  263.     }    
  264.  
  265. void    picture_clear()                        /* 消去 */
  266.     {
  267.     int    wx,wy;
  268.  
  269.     close();
  270.  
  271.     picture_buf1.x = 0;
  272.     picture_buf1.y = 0;
  273.     strcpy(picture_buf1.name,"消去");
  274.  
  275.     EGB_writePage(egb_work,0x81);
  276.     EGB_paintMode(egb_work,0x22);
  277.     box_full(280,30,319,59,0x8000,0x8000,0);
  278.     sprint("消去",284,52,0x7fff,0,16,16,1);
  279.     EGB_writePage(egb_work,0);
  280.     wx = win[active].wx;
  281.     wy = win[active].wy;
  282.     box_full(wx+87,wy+53,wx+205,wy+65,4,4,0);
  283.     sprint("消去",wx+87,313,15,8,12,12,4);
  284.     }
  285.  
  286. void    picture_load_sel()
  287.     {
  288.     file_sel(2);
  289.     }
  290.  
  291. void    picture_sel()
  292.     {
  293.     BUTTON    *p;
  294.     int    wx,wy;
  295.  
  296.     wx = win[1].wx+121;
  297.     wy = win[active].last->by+14;
  298.     p = window_open(wx,wy,50,63,526,0);
  299.     p = create(p,6,6,38,15,1,picture_load_sel);
  300.     p = create(p,6,23,38,15,1,picture_clear);
  301.     p = create(p,12,41,31,17,0,close);
  302.     }
  303.  
  304. void    position()
  305.     {
  306.     if (picture_buf1.name[0] != '\0')
  307.         {
  308.         if (strcmp(picture_buf1.name,"消去") != 0)
  309.             {
  310.             strcpy(picture_buf2.name, picture_buf1.name);
  311.             picture_pos(picture_buf1.name);
  312.             }
  313.         }
  314.     }
  315.  
  316. void    set_picture()        /* パソコン画像ウィンドウで設定が押された */
  317.     {
  318.     int    x,y, vx, stp;
  319.     char    *p;
  320.  
  321.     if ((picture_buf1.effect == 0) || (picture_buf1.name[0] == '\0'))
  322.         {
  323.         vx = win[1].wx;
  324.         err_window(0,vx+5,280);
  325.         }
  326.     else
  327.         {
  328.         stp = step + (win[0].last->number)/5;
  329.         data[stp].picture.flag = 1;
  330.         data[stp].picture.effect = picture_buf1.effect;
  331.         data[stp].picture.x = picture_buf1.x;
  332.         data[stp].picture.y = picture_buf1.y;
  333.         strcpy(data[stp].picture.name, picture_buf1.name);
  334.         close();
  335.  
  336.         x = stp % 8 * 40;
  337.         y = stp / 8 * 30+60;
  338.         EGB_writePage(egb_work,0x81);
  339.         p = get_vram(32,280,30,319,59);
  340.         put_vram(p,x,y,x+39,y+29);
  341.         free(p);
  342.         picture_print(stp,((win[0].last->number/5)*89+102)/2,91);
  343.         EGB_writePage(egb_work,0);
  344.         }
  345.     }
  346.  
  347. void    picture()                    /* パソコン画像のウィンドウを開く */
  348.     {
  349.     BUTTON    *p;
  350.     int    wx, stp;
  351.     char    *pic;
  352.     int    x,y;
  353.  
  354.     wx = win[active].last->bx-65;
  355.     p = window_open(wx,248,211,110,0,218);
  356.     p = create(p,86,35,120,14,0,effect);
  357.     p = create(p,86,52,120,14,0,picture_sel);
  358.     p = create(p,86,69,120,14,0,position);
  359.     p = create(p,137,89,32,17,0,set_picture);
  360.     p = create(p,173,89,31,17,0,close);
  361.  
  362.     stp = step + (win[0].last->number)/5;
  363.     if (data[stp].picture.flag == 1)
  364.         {
  365.         picture_buf1.effect = data[stp].picture.effect;
  366.         picture_buf1.x = data[stp].picture.x;
  367.         picture_buf1.y = data[stp].picture.y;
  368.         strcpy(picture_buf1.name, data[stp].picture.name);
  369.  
  370.         sprint(eff_str[picture_buf1.effect-1],wx+86,295,15,8,12,12,4);
  371.  
  372.         if (strcmp(picture_buf1.name,"消去") != 0)
  373.             {
  374.             sprint(pic_name(picture_buf1.name),wx+87,313,15,8,12,12,4);
  375.             sprint("X:     Y:",wx+87,330,15,8,12,12,4);
  376.             sprintusing(picture_buf1.x*2,3,wx+111,330,15,8,12,12,4);
  377.             sprintusing(picture_buf1.y*2,3,wx+159,330,15,8,12,12,4);
  378.             }
  379.         else
  380.             {
  381.             sprint("消去",wx+87,313,15,8,12,12,4);
  382.             }            
  383.  
  384.         x = stp % 8 * 40;
  385.         y = stp / 8 * 30+60;
  386.         EGB_writePage(egb_work,0x81);
  387.         pic = get_vram(32,x,y,x+39,y+29);
  388.         put_vram(pic,280,30,319,59);
  389.         free(pic);
  390.         EGB_writePage(egb_work,0);
  391.         }
  392.     else
  393.         {
  394.         picture_buf1.effect = 0;
  395.         picture_buf1.x = 0;
  396.         picture_buf1.y = 0;
  397.         picture_buf1.name[0] = '\0';
  398.         }
  399.     }
  400.  
  401. /******************************************************************************
  402.  *    ビデオ画像ウィンドウ
  403.  */
  404.  
  405. void    simpose()                /* ス-パ-インポ-ズの設定 */
  406.     {
  407.     int    x,y;
  408.     effect_buf.spimpose = 1-effect_buf.spimpose;
  409.  
  410.     x = win[active].last->bx;
  411.     y = win[active].last->by;
  412.  
  413.     EGB_paintMode(egb_work,0x22);
  414.     box_full(x+1,y+1,x+119,y+12,4,4,0);
  415.     sprint(state[effect_buf.spimpose],x,y+12,15,8,12,12,4);
  416.     }
  417.  
  418. void    effect_print(int effect, int x, int y)
  419.     {
  420.     char    *p;
  421.     int    dx,dy;
  422.  
  423.     dx = ((effect)%8)*40;
  424.     dy =  (effect /8)*30;
  425.     EGB_writePage(egb_work,0x81);
  426.     p = get_vram(32,dx,dy,dx+39,dy+29);
  427.     EGB_writePage(egb_work,1);
  428.     put_vram(p,x,y,x+39,y+29);
  429.     EGB_writePage(egb_work,0);
  430.     free(p);
  431.     }
  432.  
  433. void    set_video()                /* 設定ボタンが押された */
  434.     {
  435.     int    stp, vx,dx,dy;
  436.  
  437.     if (effect_buf.effect == 0)
  438.         {
  439.         vx = win[1].wx;
  440.         err_window(0,vx+34,230);
  441.         }
  442.     else
  443.         {
  444.         stp = step + (win[0].last->number)/5;
  445.  
  446.         data[stp].effect.flag = 1;
  447.         data[stp].effect.effect = effect_buf.effect;
  448.         data[stp].effect.spimpose = effect_buf.spimpose;
  449.  
  450.         dx = win[0].last->bx/2;
  451.         dy = win[0].last->by/2;
  452.         effect_print(effect_buf.effect-1,dx,dy);
  453.         close();
  454.         }
  455.     }
  456.     
  457. void    video_win()                /* ビデオ画像ウィンドウを開く */
  458.     {
  459.     BUTTON    *p;
  460.     int    vx, stp;
  461.  
  462.     vx = win[active].last->bx - 85;
  463.     p = window_open(vx,178,246,95,76,0);
  464.     p = create(p, 121, 35,120, 13, 0, effect);
  465.     p = create(p, 121, 51,120, 13, 0, simpose);
  466.     p = create(p, 171, 74, 32, 17, 0, set_video);
  467.     p = create(p, 206, 74, 32, 17, 0, close);
  468.  
  469.     stp = step + (win[0].last->number)/5;
  470.     if (data[stp].effect.flag == 1)
  471.         {
  472.         effect_buf.effect = data[stp].effect.effect;
  473.         effect_buf.spimpose = data[stp].effect.spimpose;
  474.  
  475.         sprint(eff_str[effect_buf.effect-1],vx+121,225,15,8,12,12,4);
  476.         }
  477.     else
  478.         {
  479.         effect_buf.effect = 0;
  480.         effect_buf.spimpose = 0;
  481.         }
  482.     sprint(state[effect_buf.spimpose],vx+121,241,15,8,12,12,4);
  483.     }
  484.  
  485. /******************************************************************************
  486.  *    CDプレイヤウィンドウ
  487.  */
  488.  
  489. void    cd_print(int i)
  490.     {
  491.     int    tr,st;
  492.  
  493.     tr = data[step+i].cd.track+1;
  494.     st = data[step+i].cd.state;
  495.  
  496.     switch(st)
  497.         {
  498.         case    0:sprint("PLAY ",i*89+104,275,13,0,16,16,1);
  499.                 sprintusing(tr,2,i*89+164,275,15,0,16,16,1);    break;
  500.         case    1:sprint("  STOP  ",i*89+106,275,10,0,16,16,1);    break;
  501.         case    2:sprint("FADE-IN",i*89+104,275,14,0,16,16,1);
  502.                 sprintusing(tr,2,i*89+164,275,15,0,16,16,1);    break;
  503.         case    3:sprint("FADE-OUT",i*89+110,275, 3,0,16,16,1);    break;
  504.         }
  505.     }
  506.  
  507. void    print_track(int tr)        /* トラックナンバ-表示 */
  508.     {
  509.     int    wx,wy;
  510.  
  511.     wx = win[active].wx;
  512.     wy = win[active].wy;
  513.  
  514.     EGB_paintMode(egb_work,0x22);
  515.     box_full(wx+90,wy+34,wx+111,wy+46,4,4,0);
  516.     sprintusing(tr,2,wx+90,wy+46,15,8,24,12,0);
  517.     }
  518.  
  519. void    track_up()                /* トラックナンバ  アップ */
  520.     {
  521.     if (cd_buf.track<98)    { cd_buf.track++; }
  522.     print_track(cd_buf.track+1);
  523.     }
  524.  
  525. void    track_down()            /* トラックナンバ-  ダウン */
  526.     {
  527.     if (cd_buf.track>0)    { cd_buf.track--; }
  528.     print_track(cd_buf.track+1);
  529.     }
  530.  
  531. void    ch_state()                /* 状態チェンジ */
  532.     {
  533.     int    wx,wy;
  534.  
  535.     cd_buf.state++;
  536.     if (cd_buf.state>3)    { cd_buf.state = 0; }
  537.  
  538.     wx = win[active].wx;
  539.     wy = win[active].wy;
  540.     EGB_paintMode(egb_work,0x22);
  541.     box_full(wx+59,wy+52,wx+142,wy+64,4,4,0);
  542.     sprint(state[cd_buf.state+2],wx+59,wy+64,15,8,12,12,4);
  543.     }
  544.  
  545. void    cd_play()
  546.     {
  547.     play_cd_da(cd_buf.track);
  548.     }
  549.  
  550. void    cd_stop()
  551.     {
  552.     setmos(82);
  553.     cdr_mstop(0);
  554.     setmos(81);
  555.     }
  556.  
  557. void    cd_set()                        /* 設定ボタンが押された */
  558.     {
  559.     int    stp,i;
  560.  
  561.     i = (win[0].last->number)/5;
  562.     stp = step + i;
  563.     data[stp].cd.flag  = 1;
  564.     data[stp].cd.track = cd_buf.track;
  565.     data[stp].cd.state = cd_buf.state;
  566.  
  567.     EGB_paintMode(egb_work,0x22);
  568.     box_full(102+i*89,252,181+i*89,283,0,0,0);
  569.     cd_print(i);
  570.     close();
  571.     }
  572.  
  573. void    cd_win()
  574.     {
  575.     BUTTON    *p;
  576.     int    vx, stp;
  577.  
  578.     vx = win[active].last->bx - 34;
  579.     p = window_open(vx,288,148,91,374,218);
  580.     p = create(p,  72, 34, 12, 12, 2, track_down);
  581.     p = create(p, 117, 34, 12, 12, 2, track_up);
  582.     p = create(p,  58, 51, 85, 14, 0, ch_state);
  583.     p = create(p,   4, 70, 32, 17, 0, cd_play);
  584.     p = create(p,  40, 70, 32, 17, 0, cd_stop);
  585.     p = create(p,  77, 70, 32, 17, 0, cd_set);
  586.     p = create(p, 113, 70, 31, 17, 0, close);
  587.  
  588.     stp = step + (win[0].last->number)/5;
  589.     if (data[stp].cd.flag == 1)
  590.         {
  591.         cd_buf.track = data[stp].cd.track;
  592.         cd_buf.state = data[stp].cd.state;
  593.         }
  594.     else
  595.         {
  596.         cd_buf.track = 0;
  597.         cd_buf.state = 0;
  598.         }
  599.  
  600.     print_track(cd_buf.track+1);
  601.     sprint(state[cd_buf.state+2],vx+59,352,15,8,12,12,4);
  602.     }
  603.  
  604. /******************************************************************************
  605.  *    効果音ウィンドウ
  606.  */
  607.  
  608. void    disp_vol(int dx, int dy, int vol)
  609.     {
  610.     int    co;
  611.  
  612.     if (vol<24)    { co = 11; }
  613.     else        { co = 10; }
  614.  
  615.     line(vol*2+dx, dy, vol*2+dx, dy+10, co);
  616.     }
  617.  
  618. void    clear_vol(int dx,int dy, int vol)
  619.     {
  620.     line(vol*2+dx, dy, vol*2+dx, dy+10,  4);
  621.     }
  622.  
  623. void    sound_vol_up()
  624.     {
  625.     int    wx,wy;
  626.  
  627.     wx = win[active].wx;
  628.     wy = win[active].wy;
  629.     if (sound_buf.vol < 31)
  630.         {
  631.         sound_buf.vol++;
  632.         disp_vol(wx+76, wy+51, sound_buf.vol);
  633.         }
  634.     }
  635.  
  636. void    sound_vol_down()
  637.     {
  638.     int    wx,wy;
  639.  
  640.     wx = win[active].wx;
  641.     wy = win[active].wy;
  642.  
  643.     if (sound_buf.vol > 0)
  644.         {
  645.         clear_vol(wx+76, wy+51, sound_buf.vol);
  646.         sound_buf.vol--;
  647.         }
  648.     }
  649.  
  650. void    sound_print(int i)
  651.     {
  652.     sprint(pic_name(data[step+i].sound.name),i*89+106,316,15,0,12,12,0);
  653.     }
  654.  
  655. void    sound_sel()
  656.     {
  657.     file_sel(3);
  658.     }
  659.  
  660. void    sound_name()                    /* ファイル名の設定 */
  661.     {
  662.     int    wx,wy;
  663.     char    *crrdir = NULL;
  664.  
  665.     close();
  666.     crrdir = _getcwd(crrdir,256);
  667.     if (strlen(crrdir) > 3)    { strcat(crrdir,"\\"); }
  668.     strcat(crrdir,key_buff);
  669.     strcpy(sound_buf.name, crrdir);
  670.  
  671.     wx = win[active].wx;
  672.     wy = win[active].wy;
  673.     EGB_paintMode(egb_work,0x22);
  674.     box_full(wx+65,wy+34,wx+142,wy+46,4,4,0);
  675.     sprint(pic_name(sound_buf.name),wx+65,wy+46,15,8,12,12,4);
  676.     }    
  677.  
  678. void    sound_play()                    /* PCM再生 */
  679.     {
  680.     int    wx,wy;
  681.  
  682.     SND_pcm_play_stop(71);
  683.     free(snd_bp);
  684.     if ((snd_bp = snd_load(sound_buf.name)) == NULL)
  685.         {
  686.         snd_bp = malloc(1);        /* dummy */
  687.         wx = win[active].wx;
  688.         wy = win[active].wy;
  689.  
  690.         switch(err)
  691.             {
  692.             case    1:err_window( 1,wx-26,wy+14);    break;
  693.             case    2:err_window( 9,wx-26,wy+14);    break;
  694.             case    3:err_window(10,wx-26,wy+14);    break;
  695.             }
  696.         return;
  697.         }
  698.  
  699.     snd_play(snd_bp,sound_buf.vol);
  700.     }
  701.  
  702. void    sound_stop()
  703.     {
  704.     SND_pcm_play_stop(71);
  705.     }
  706.  
  707. void    set_sound()                        /* 設定ボタンが押された */
  708.     {
  709.     int    stp,i,wx,wy;
  710.  
  711.     i = (win[0].last->number)/5;
  712.     stp = step + i;
  713.     wx = win[active].wx;
  714.     wy = win[active].wy;
  715.  
  716.     if (strcmp(sound_buf.name,"") == 0)
  717.         { err_window(8,wx-26,wy+14); }
  718.     else
  719.         {
  720.         data[stp].sound.flag = 1;
  721.         data[stp].sound.vol = sound_buf.vol;
  722.         strcpy(data[stp].sound.name,sound_buf.name);
  723.         EGB_paintMode(egb_work,0x22);
  724.         box_full(102+i*89,294,181+i*89,325,0,0,0);
  725.         sound_print(i);
  726.         close();
  727.         }
  728.     }
  729.  
  730. void    sound_win()
  731.     {
  732.     BUTTON    *p;
  733.     int    i,vx, stp;
  734.  
  735.     vx = win[active].last->bx - 34;
  736.     p = window_open(vx,330,159,94,165,330);
  737.     p = create(p,  60, 33, 94, 14, 0, sound_sel);
  738.     p = create(p,  60, 51, 12, 12, 2, sound_vol_down);
  739.     p = create(p, 142, 51, 12, 12, 2, sound_vol_up);
  740.     p = create(p,   6, 71, 32, 17, 0, sound_play);
  741.     p = create(p,  42, 71, 32, 17, 0, sound_stop);
  742.     p = create(p,  86, 71, 32, 17, 0, set_sound);
  743.     p = create(p, 122, 71, 31, 17, 0, close);
  744.  
  745.     stp = step + (win[0].last->number)/5;
  746.     if (data[stp].sound.flag == 1)
  747.         {
  748.         sound_buf.vol = data[stp].sound.vol;
  749.         strcpy(sound_buf.name,data[stp].sound.name);
  750.         sprint(pic_name(sound_buf.name),vx+65,376,15,8,12,12,4);
  751.         if (sound_buf.vol>0)
  752.             {
  753.             for(i=1 ; i<sound_buf.vol+1 ; i++)
  754.                 {
  755.                 disp_vol(vx+76, 330+51, i);
  756.                 }
  757.             }
  758.         }
  759.     else
  760.         {
  761.         sound_buf.vol = 0;
  762.         strcpy(sound_buf.name,"");
  763.         }
  764.     }
  765.  
  766. /******************************************************************************
  767.  *    ミキシングウィンドウ
  768.  */
  769.  
  770. void    disp_all_vol()
  771.     {
  772.     int    i,j, wx,wy, vol;
  773.  
  774.     wx = win[active].wx;
  775.     wy = win[active].wy;
  776.     for (i=0 ; i<3 ; i++)
  777.         {
  778.         vol = mixing_buf.vol[i];
  779.         if (vol>0)
  780.             {
  781.             for(j=1 ; j<vol+1 ; j++)
  782.                 {
  783.                 disp_vol(wx+76,i*17+wy+33,j);
  784.                 }
  785.             }
  786.         }
  787.     }
  788.  
  789. void    vol_up()
  790.     {
  791.     int    p,wx,wy;
  792.  
  793.     p = (win[active].last->number)/2;
  794.     wx = win[active].wx;
  795.     wy = win[active].wy;
  796.     if (mixing_buf.vol[p] < 31)
  797.         {
  798.         mixing_buf.vol[p]++;
  799.         disp_vol(wx+76, p*17+wy+33, mixing_buf.vol[p]);
  800.         }
  801.     }
  802.  
  803. void    vol_down()
  804.     {
  805.     int    p,wx,wy;
  806.  
  807.     wx = win[active].wx;
  808.     wy = win[active].wy;
  809.     p = (win[active].last->number)/2;
  810.  
  811.     if (mixing_buf.vol[p] > 0)
  812.         {
  813.         clear_vol(wx+76, p*17+wy+33, mixing_buf.vol[p]);
  814.         mixing_buf.vol[p]--;
  815.         }
  816.     }
  817.  
  818. void    set_mix()
  819.     {
  820.     int    dx,dy, stp;
  821.  
  822.     stp = step + (win[0].last->number)/5;
  823.  
  824.     data[stp].mixing.flag = 1;
  825.     data[stp].mixing.vol[0] = mixing_buf.vol[0];
  826.     data[stp].mixing.vol[1] = mixing_buf.vol[1];
  827.     data[stp].mixing.vol[2] = mixing_buf.vol[2];
  828.  
  829.     dx = win[0].last->bx;
  830.     dy = win[0].last->by;
  831.     sprint("設定あり",dx+8,dy+23,15,0,16,16,1);
  832.  
  833.     close();
  834.     }
  835.  
  836. void    mixing()
  837.     {
  838.     BUTTON    *p;
  839.     int    vx,stp,i;
  840.  
  841.     vx = win[active].last->bx - 39;
  842.     p = window_open(vx,370,159,110,213,218);
  843.     for(i=0 ; i<3 ; i++)
  844.         {
  845.         p = create(p,  60, i*17+33,12, 12, 2, vol_down);
  846.         p = create(p, 142, i*17+33,12, 12, 2, vol_up);
  847.         }
  848.     p = create(p,  86, 87, 32, 17, 0, set_mix);
  849.     p = create(p, 122, 87, 31, 17, 0, close);
  850.  
  851.     stp = step + (win[0].last->number)/5;
  852.     if (data[stp].mixing.flag == 1)
  853.         {
  854.         mixing_buf.vol[0] = data[stp].mixing.vol[0];
  855.         mixing_buf.vol[1] = data[stp].mixing.vol[1];
  856.         mixing_buf.vol[2] = data[stp].mixing.vol[2];
  857.         disp_all_vol();
  858.         }
  859.     else
  860.         {
  861.         mixing_buf.vol[0] = 0;
  862.         mixing_buf.vol[1] = 0;
  863.         mixing_buf.vol[2] = 0;
  864.         disp_all_vol();
  865.         }
  866.     }
  867.